<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>登陆</title>
<link rel="stylesheet" type="text/css" href="<{$preStaticUrl}>/Admin/css/common.css"/>
<link rel="stylesheet" type="text/css" href="<{$preStaticUrl}>/Admin/css/index.css"/>
<link rel="stylesheet" type="text/css" href="<{$preStaticUrl}>/Admin/js/lib/layer/skin/layer.css"/>
<script src="http://static.geetest.com/static/tools/gt.js"></script>
<script src="<{$preStaticUrl}>/Admin/js/lib/require.js"></script>
<script src="<{$preStaticUrl}>/Admin/js/lib/requireConfig.js"></script>
<script>
require(["jquery","angular","layer"],function($,angular,layer){
	$.ajax({
		// 获取id，challenge，success（是否启用failback）
		url: "<{U('StartCaptchaServlet')}>", // 加随机数防止缓存
		type: "get",
		dataType: "json",
		success: function (data) {
			// 使用initGeetest接口
			// 参数1：配置参数
			// 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
			initGeetest({
				gt: data.gt,
				challenge: data.challenge,
				product: "popup", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
				offline: !data.success // 表示用户后台检测极验服务器是否宕机，与SDK配合，用户一般不需要关注
			}, handlerPopup);
		}
	});

	var handlerPopup = function (captchaObj) {
		$("#popup-submit").click(function () {
			var validate = captchaObj.getValidate();
			if (!validate) {
				alert('请先完成验证！');
				return;
			}
			$.ajax({
				url: "<{u('check_login')}>", // 加随机数防止缓存
				type: "post",
				dataType: "json",
				data: {
					// 二次验证所需的三个值
					userName:$('#userName').val(),
					passWord:$('#passWord').val(),
					geetest_challenge: validate.geetest_challenge,
					geetest_validate: validate.geetest_validate,
					geetest_seccode: validate.geetest_seccode,

				},
				success: function (result) {

					if (result.status == 1) {
						layer.msg("登陆成功，正在转入管理后台");
						location.href="<{U('index/index')}>";
					} else {
						layer.msg(result.info);
					}
				}
			});
		});
		// 弹出式需要绑定触发验证码弹出按钮
		captchaObj.bindOn("#popup-submit");
		// 将验证码加到id为captcha的元素里
		captchaObj.appendTo(".alertTxt");
		// 更多接口参考：http://www.geetest.com/install/sections/idx-client-sdk.html
	};




  angular.module("app", []).controller("xyController",function($scope){

    $scope.downloadChrome = function(){
    	alert("您将要开始下载Chrome浏览器");
    }
  });

  angular.bootstrap(document,["app"]);
});

</script>
</head>
<body ng-controller="xyController" class="loginPage">
<form action="<{$postUrl}>" method="post" id="loginForm">
	<div class="abosuluteCenter pageContent hAlignCenterDiv">
		
			<div class="xyLogo" style="margin-top: 30px;"></div>
			<div class="accountInput"><input type="text" class="userInfoInput" id="userName" ng-model="accountV"/></div>
			<div class="passwordInput"><input type="password" class="userInfoInput" id="passWord" ng-model="passwordV"/></div>
			<div style="margin-top: 30px;">
				<a class="xy-button" id="popup-submit">登陆</a>
			</div>
			<div class="poweredTxt">Powered by MeatBall Mother  2015-2018  丸子妈妈</div>
			<div class="alertTxt"><a ng-click="downloadChrome()">点击下载Chrome浏览器（谷歌），否则某些功能有可能无法使用！</a></div>
		
	</div>
	</form>
</body>
</html>

